<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
    /**
     * @var Zend_Log
     */
    protected $_logger;
    
    public $frontController;
    
    protected function _initLogging()
    {
        $this->bootstrap('frontController');
        $logger = new Zend_Log();

        $writer = 'production' == $this->getEnvironment() ?
			new Zend_Log_Writer_Stream(APPLICATION_PATH . '/../data/logs/app.log') :
			new Zend_Log_Writer_Firebug();
        $logger->addWriter($writer);

		if ('production' == $this->getEnvironment()) {
			$filter = new Zend_Log_Filter_Priority(Zend_Log::CRIT);
			$logger->addFilter($filter);
		}

        $this->_logger = $logger;
        Zend_Registry::set('log', $logger);
    }
    
    protected function _initDefaultModuleAutoloader()
    {
        $this->_logger->info('Bootstrap ' . __METHOD__);
        
        $this->_resourceLoader = new Zend_Application_Module_Autoloader(array(
            'namespace' => 'News',
            'basePath'  => APPLICATION_PATH . '/modules/news',
        ));
        $this->_resourceLoader->addResourceTypes(array(
            'modelResource' => array(
              'path'      => 'models/resources',
              'namespace' => 'Resource',
            ),
            'service'	=> array(
                'path'	=> 'services',
                'namespace'	=> 'Service',
            ),
        ));
    }
    
    protected function _initLocale()
    {
        $locale = new Zend_Locale('zh_CN');
        Zend_Registry::set('Zend_Locale', $locale);
    }
    
    protected function _initViewSettings()
    {
        $this->bootstrap('view');
        $this->_view = $this->getResource('view');
        
        // set encoding and doctype
        $this->_view->setEncoding('UTF-8');
        $this->_view->doctype('XHTML1_TRANSITIONAL');
        $this->_view->skin = 'default';
        $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');

        // set the content type and language
        $this->_view->headMeta()->appendHttpEquiv('Content-Type', 'text/html; charset=UTF-8');
        $this->_view->headMeta()->appendHttpEquiv('Content-Language', 'zh-cn');

        // set css links and a special import for the accessibility styles
        //$this->_view->headStyle()->setStyle('@import "/css/access.css";');
        //$this->_view->headLink()->appendStylesheet('/css/news.css');
        //$this->_view->headLink()->appendStylesheet('/css/main.css');
        //$this->_view->headLink()->appendStylesheet('/css/form.css');

        // setting the site in the title
        $this->_view->headTitle('光明小学');

        // setting a separator string for segments:
        $this->_view->headTitle()->setSeparator(' - ');
        
    }

}